//
//  NovelCell.m
//  ChineseCollegeStudentsNetwork
//
//  Created by Zheng on 2019/3/21.
//  Copyright © 2019 刘喆. All rights reserved.
//

#import "NovelCell.h"
#import "NovelModel.h"

@implementation NovelCell {
    UILabel *titleLbl;
    UILabel *statusLbl;
}

- (void)setModel:(NovelModel *)model {
    _model = model;
    
    titleLbl.text = _model.title;
    
    statusLbl.hidden = _model.isFree.integerValue == 0? YES: NO;
}

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        
        titleLbl = [[UILabel alloc] init];
        titleLbl.font = [UIFont systemFontOfSize:12 weight:UIFontWeightRegular];
        [self.contentView addSubview:titleLbl];
        [titleLbl mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.offset(12);
            make.centerY.offset(0);
        }];
        
        statusLbl = [[UILabel alloc] init];
        statusLbl.font = [UIFont systemFontOfSize:12 weight:UIFontWeightRegular];
        statusLbl.backgroundColor = kColorTint;
        statusLbl.textColor = [UIColor whiteColor];
        statusLbl.hidden = YES;
        statusLbl.layer.cornerRadius = 5;
        statusLbl.layer.masksToBounds = YES;
        statusLbl.text = @"免费试读";
        statusLbl.textAlignment = NSTextAlignmentCenter;
        [self.contentView addSubview:statusLbl];
        [statusLbl mas_makeConstraints:^(MASConstraintMaker *make) {
            make.right.offset(-15);
            make.centerY.offset(0);
            make.height.mas_equalTo(25);
            make.width.mas_equalTo(70);
        }];
    }
    return self;
}



@end
